<?php
/*
Primary Author: Derek Shue
Secondary: Alex Arey
Documentation: Cheng Yi
Updated: 12/10/2011
Module Description: The Organizations module adds/finds/updates/deletes Organizations from the database.
*/
class Application_Model_DbTable_Organizations extends Zend_Db_Table_Abstract
{

    protected $_name = 'ORGANIZATIONS';



	public function getOrganization($where)
    {
        $row = $this->fetchRow($where);
        if (!$row) {
            throw new Exception("Could not find row $where");
        }
        return $row->toArray();
    }
    
    public function getAllOrganizations()
    {
    	$rows = $this->fetchAll();
    	if (!$rows) {
    		throw new Exception("Could not find entries");
    	}
    	return $rows->toArray();
    }

    public function addOrganization($id,$state, $zip, $phone, $extension, $fax, $otherphone, $website, $mission, $description, $transport, $name, $address1, $address2, $city, $county)
    {
        $data = array(
            'ID' => $id,
            'STATE' => $state,
			'ZIP' => $zip,
			'PHONE' => $phone,
			'EXTENSION' => $extension,
			'FAX' => $fax,
			'OTHERPHONE' => $otherphone,

			'WEBSITE' => $website,
			'MISSION' => $mission,
			'DESCRIPTION' => $description,
			'TRANSPORT' => $transport,
			'NAME' => $name,
			'ADDRESS1' => $address1,
			'ADDRESS2' => $address2,
			'CITY' => $city,
			'COUNTY' => $county,
        );
        $this->insert($data);
    }

    public function updateOrganization($id, $state, $zip, $phone, $extension, $fax, $otherphone, $website, $mission, $description, $transport, $name, $address1, $address2, $city, $county)
    {
        $data = array(
            'ID' => $id,
            'STATE' => $state,
			'ZIP' => $zip,
			'PHONE' => $phone,
			'EXTENSION' => $extension,
			'FAX' => $fax,
			'OTHERPHONE' => $otherphone,
			'WEBSITE' => $website,
			'MISSION' => $mission,
			'DESCRIPTION' => $description,
			'TRANSPORT' => $transport,
			'NAME' => $name,
			'ADDRESS1' => $address1,
			'ADDRESS2' => $address2,
			'CITY' => $city,
			'COUNTY' => $county,

        );
		$data = array_filter($data);
        $this->update($data, 'ID = '. (int)$id);
    }

    public function deleteOrganization($where)
    {
        $this->delete($where);
    }

/*

STATEVARCHAR2
ZIPVARCHAR2
PHONEVARCHAR2
EXTENSIONVARCHAR2
FAXVARCHAR2
OTHERPHONEVARCHAR2
PRIMARYCONTACTNUMBER
WEBSITEVARCHAR2
MISSIONVARCHAR2
DESCRIPTIONVARCHAR2
TRANSPORTVARCHAR2
IDNUMBER
PASSWORDVARCHAR2
NAMEVARCHAR2
ADDRESS1VARCHAR2
ADDRESS2VARCHAR2
CITYVARCHAR2
COUNTYVARCHAR2
*/



}

































































































